//
//  STMNetworkAPI.m
//  StoreManagement
//
//  Created by centling on 16/5/14.
//  Copyright © 2016年 alfred. All rights reserved.
//

#import "STMNetworkAPI.h"
#import "NetworkClient.h"

@implementation STMNetworkAPI


//首页数据获取
+ (void)getHomePageDataWithKey:(NSString *)userKey
                       success:(void (^)(STMHomePageModel *result))success
                       failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_center&op=index"
                              params:parameters
                             success:^(id response) {
                                 STMHomePageModel *info = [[STMHomePageModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//登录
+ (void)loginWithUserName:(NSString *)userName
                 password:(NSString *)password
                  success:(void (^)(STMLoginModel *))success
                  failure:(void (^)(NSError *))failure {
    NSDictionary *parameters = @{@"seller_name":userName,
                                 @"password":password,
                                 @"client":@"ios"
                                };

    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_login&op=index"
                              params:parameters
                             success:^(id response) {
                                 
                                 STMLoginModel *info = [[STMLoginModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                                 
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//退出登录
+ (void)logoutWithKey:(NSString *)userKey
           sellerName:(NSString *)sellerName
               client:(NSString *)client
              success:(void (^)(STMLoginModel *result))success
              failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"seller_name":sellerName,
                                 @"client":client
                                 };
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_logout&op=index"
                              params:parameters
                             success:^(id response) {
                                 
                                 STMLoginModel *info = [[STMLoginModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                                 
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}


//密码修改
+ (void)modifyPwdWithSellerName:(NSString *)sellerName
                         newPwd:(NSString *)newPwd
                        success:(void (^)(STMLoginModel *result))success
                        failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"seller_name":sellerName,
                                 @"password":newPwd
                                 };
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_login&op=new_pass"
                              params:parameters
                             success:^(id response) {
                                 
                                 STMLoginModel *info = [[STMLoginModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                                 
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}


//店铺管理信息获取
+ (void)getShopInfoWithKey:(NSString *)userkey
                   success:(void (^)(STMShopInfoModel *result))success
                   failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userkey};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_store&op=store_statistics"
                              params:parameters
                             success:^(id response) {
                                 STMShopInfoModel *info = [[STMShopInfoModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//店铺管理信息修改
+ (void)shopInfoEditWithKey:(NSString *)userKey
                storeAvatar:(NSData *)avatarData
                         qq:(NSString *)qq
                         ww:(NSString *)ww
                      phone:(NSString *)phone
                    success:(void (^)(STMShopInfoModel *result))success
                    failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"store_qq":qq,
                                 @"store_ww":ww,
                                 @"store_phone":phone};
    
    [NetworkClient requestWithUrl:@"index.php?act=seller_store&op=store_edit"
                           params:parameters
                         filePath:avatarData
                     fileParamKey:@"store_avatar"
                          success:^(id response) {
                              STMShopInfoModel *info = [[STMShopInfoModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                              success(info);
                          }
                          failure:^(NSError *err) {
                              failure(err);
                          }];
}


//TOP10流量获取
+ (void)getTopTenFLowWithKey:(NSString *)userkey
                     success:(void (^)(STMTopGoodsflowModel *result))success
                     failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userkey};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_stat&op=goodsflow"
                              params:parameters
                             success:^(id response) {
                                 STMTopGoodsflowModel *info = [[STMTopGoodsflowModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//TOP10下单金额获取
+ (void)getTopTenMoneyAmountWithKey:(NSString *)userkey
                            success:(void (^)(STMTopGoodsflowModel *result))success
                            failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userkey};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_stat&op=goodsamount"
                              params:parameters
                             success:^(id response) {
                                 STMTopGoodsflowModel *info = [[STMTopGoodsflowModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}


//TOP10下单量获取
+ (void)getTopTenOrderAmountWithKey:(NSString *)userkey
                            success:(void (^)(STMTopGoodsflowModel *result))success
                            failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userkey};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_stat&op=goodsnum"
                              params:parameters
                             success:^(id response) {
                                 STMTopGoodsflowModel *info = [[STMTopGoodsflowModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];

}

//订单统计下单金额获取
+ (void)getOrderAmountWithKey:(NSString *)userkey
                      statype:(NSString *)statype
                      success:(void (^)(STMOrderStatisticsModel *result))success
                      failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userkey,
                                 @"stattype":statype};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_stat&op=ordersamount"
                              params:parameters
                             success:^(id response) {
                                 STMOrderStatisticsModel *info = [[STMOrderStatisticsModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//订单统计下单量获取
+ (void)getOrderNumWithKey:(NSString *)userkey
                      statype:(NSString *)statype
                      success:(void (^)(STMOrderStatisticsModel *result))success
                      failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userkey,
                                 @"stattype":statype};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_stat&op=ordersnum"
                              params:parameters
                             success:^(id response) {
                                 STMOrderStatisticsModel *info = [[STMOrderStatisticsModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//订单管理实物订单列表获取
+ (void)getOrderManagementTrueListWithKey:(NSString *)userKey
                        orderType:(NSString *)orderType
                       orderCount:(NSString *)orderCount
                          success:(void (^)(STMOrderManagementListModel *result))success
                          failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"order_type":orderType,
                                 @"order_count":orderCount};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_order&op=order_list"
                              params:parameters
                             success:^(id response) {
                                 STMOrderManagementListModel *info = [[STMOrderManagementListModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//商品管理列表
+ (void)getGoodsManagementListWithKey:(NSString *)userKey
                            goodsType:(NSString *)goodsType
                                 page:(NSString *)page
                              success:(void (^)(STMGoodsListModel *result))success
                              failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"goods_type":goodsType};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:[NSString stringWithFormat:@"index.php?act=seller_goods&op=goods_list&curpage=%@",page]
                              params:parameters
                             success:^(id response) {
                                 STMGoodsListModel *info = [[STMGoodsListModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//咨询管理列表
+ (void)getConsultManagementListWithKey:(NSString *)userKey
                                storeId:(NSString *)storeId
                                   type:(NSString *)type
                                   page:(NSString *)page
                                success:(void (^)(STMConsultManagementModel *result))success
                                failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"store_id":storeId,
                                 @"type":type};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:[NSString stringWithFormat:@"index.php?act=store_consult&curpage=%@",page]
                              params:parameters
                             success:^(id response) {
                                 STMConsultManagementModel *info = [[STMConsultManagementModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//咨询回复
+ (void)consultReplyWithKey:(NSString *)userKey
                    storeId:(NSString *)storeId
                  consultId:(NSString *)consultId
                    content:(NSString *)content
                    success:(void (^)(STMLoginModel *result))success
                    failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"store_id":storeId,
                                 @"consult_id":consultId,
                                 @"content":content};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:[NSString stringWithFormat:@"index.php?act=store_consult&op=reply_save"]
                              params:parameters
                             success:^(id response) {
                                 STMLoginModel *info = [[STMLoginModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}


//退款列表
+ (void)getStoreRefundListWityKey:(NSString *)userKey
                             lock:(NSString *)lock
                            state:(NSString *)state
                             page:(NSString *)page
                          success:(void (^)(STMStoreRefundModel *result))success
                          failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"lock":lock,
                                 @"state":state};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:[NSString stringWithFormat:@"index.php?act=store_refund&op=index&curpage=%@",page]
                              params:parameters
                             success:^(id response) {
                                 STMStoreRefundModel *info = [[STMStoreRefundModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}


//退款审核
+ (void)refundAuditWithKey:(NSString *)userKey
                  refundId:(NSString *)refundId
               sellerState:(NSString *)sellerState
             sellerMessage:(NSString *)sellerMessage
                   success:(void (^)(STMLoginModel *result))success
                   failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"refund_id":refundId,
                                 @"seller_state":sellerState,
                                 @"seller_message":sellerMessage};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:[NSString stringWithFormat:@"index.php?act=store_refund&op=edit"]
                              params:parameters
                             success:^(id response) {
                                 STMLoginModel *info = [[STMLoginModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}


//退货列表
+ (void)getStoreReturnListWityKey:(NSString *)userKey
                             lock:(NSString *)lock
                            state:(NSString *)state
                             page:(NSString *)page
                          success:(void (^)(STMStoreRefundModel *result))success
                          failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"lock":lock,
                                 @"state":state};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:[NSString stringWithFormat:@"index.php?act=store_return&op=index&curpage=%@",page]
                              params:parameters
                             success:^(id response) {
                                 STMStoreRefundModel *info = [[STMStoreRefundModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//退货审核
+ (void)goodsReturnAuditWithKey:(NSString *)userKey
                       refundId:(NSString *)refundId
                    sellerState:(NSString *)sellerState
                  sellerMessage:(NSString *)sellerMessage
                     returnType:(NSString *)returnType
                        success:(void (^)(STMLoginModel *result))success
                        failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"refund_id":refundId,
                                 @"seller_state":sellerState,
                                 @"seller_message":sellerMessage,
                                 @"return_type":returnType};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:[NSString stringWithFormat:@"index.php?act=store_return&op=edit"]
                              params:parameters
                             success:^(id response) {
                                 STMLoginModel *info = [[STMLoginModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}


//商店流量获取
+ (void)getStoreFlowWithKey:(NSString *)userKey
                   stattype:(NSString *)stattype
                    success:(void (^)(STMStoreFlowModel *result))success
                    failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"stattype":stattype};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_stat&op=storeflow"
                              params:parameters
                             success:^(id response) {
                                 STMStoreFlowModel *info = [[STMStoreFlowModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}


//忘记密码获取验证码
+ (void)getCaptchaWithSellerName:(NSString *)sellerName
                          mobile:(NSString *)mobile
                         success:(void (^)(STMGetCaptchaModel *result))success
                         failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"seller_name":sellerName,
                                 @"member_mobile":mobile};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_login&op=is_seller"
                              params:parameters
                             success:^(id response) {
                                 STMGetCaptchaModel *info = [[STMGetCaptchaModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//订单发货
+ (void)sendOrderWithKey:(NSString *)userKey
                 orderId:(NSString *)orderId
                 success:(void (^)(STMLoginModel *result))success
                 failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"order_id":orderId};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_order&op=order_deliver_send"
                              params:parameters
                             success:^(id response) {
                                 STMLoginModel *info = [[STMLoginModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//取消订单
+ (void)orderCancelWithKey:(NSString *)userKey
                   orderId:(NSString *)orderId
                    reason:(NSString *)reason
                   success:(void (^)(STMLoginModel *result))success
                   failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"order_id":orderId,
                                 @"reason":reason};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_order&op=order_cancel"
                              params:parameters
                             success:^(id response) {
                                 STMLoginModel *info = [[STMLoginModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//修改订单
+ (void)modifyOrderWithKey:(NSString *)userKey
               orderAmount:(NSString *)orderAmount
               goodsAmount:(NSString *)goodsAmount
               shippingFee:(NSString *)shippingFee
                   orderId:(NSString *)orderId
                   success:(void (^)(STMLoginModel *result))success
                   failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"order_amount":orderAmount,
                                 @"goods_amount":goodsAmount,
                                 @"shipping_fee":shippingFee,
                                 @"order_id":orderId};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_order&op=edit_order"
                              params:parameters
                             success:^(id response) {
                                 STMLoginModel *info = [[STMLoginModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//禁售商品删除
+ (void)deleteGoodsWithKey:(NSString *)userKey
                  commonId:(NSString *)commonId
                   success:(void (^)(STMLoginModel *result))success
                   failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"commonids":commonId};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_goods&op=goods_drop"
                              params:parameters
                             success:^(id response) {
                                 STMLoginModel *info = [[STMLoginModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//商品下架
+ (void)unshowGoodsWithKey:(NSString *)userKey
                  commonId:(NSString *)commonId
                   success:(void (^)(STMLoginModel *result))success
                   failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"commonids":commonId};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_goods&op=goods_unshow"
                              params:parameters
                             success:^(id response) {
                                 STMLoginModel *info = [[STMLoginModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//商品上架
+ (void)showGoodsWithKey:(NSString *)userKey
                commonId:(NSString *)commonId
                 success:(void (^)(STMLoginModel *result))success
                 failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey,
                                 @"commonids":commonId};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_goods&op=goods_show"
                              params:parameters
                             success:^(id response) {
                                 STMLoginModel *info = [[STMLoginModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//发布商品一级类型获取
+ (void)getGoodsCategoryWithKey:(NSString *)userKey
                        success:(void (^)(STMGoodsCategoryModel *result))success
                        failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:@"index.php?act=seller_goods&op=get_one_level_cat"
                              params:parameters
                             success:^(id response) {
                                 STMGoodsCategoryModel *info = [[STMGoodsCategoryModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//发布商品二三级类型获取
+ (void)getOtherGoodsCategoryWithKey:(NSString *)userKey
                           firstGCid:(NSString *)firstGCid
                             success:(void (^)(STMGoodsCategoryModel *result))success
                             failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:[NSString stringWithFormat:@"index.php?act=seller_goods&op=get_other_level_cat&gc_id=%@&deep=3", firstGCid]
                              params:parameters
                             success:^(id response) {
                                 STMGoodsCategoryModel *info = [[STMGoodsCategoryModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//发布商品图片上传
+ (void)uploadImageWithKey:(NSString *)userKey
                     image:(NSData *)image
                   success:(void (^)(STMUploadImageModel *result))success
                   failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey};
    
    [NetworkClient requestWithUrl:@"index.php?act=seller_goods&op=image_upload"
                           params:parameters
                         filePath:image
                     fileParamKey:@"name"
                          success:^(id response) {
                              STMUploadImageModel *info = [[STMUploadImageModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                              success(info);
                          }
                          failure:^(NSError *err) {
                              failure(err);
                          }];
}

//商品发布
+ (void)publishGoodsWithKey:(NSString *)userKey
                 imageNames:(NSString *)imageNames
                  goodsName:(NSString *)goodsName
                goodsCateId:(NSString *)goodsCateId
              goodsCateName:(NSString *)goodsCateName
                 goodsPrice:(NSString *)goodsPrice
                marketPrice:(NSString *)marketPrice
                 goodsStore:(NSString *)goodsStore
               goodsFreight:(NSString *)goodsFreight
           goodsDescription:(NSString *)goodsDescription
                    success:(void (^)(STMLoginModel *result))success
                    failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"form_submit":@"ok",
                                 @"cate_id":goodsCateId,
                                 @"cate_name":goodsCateName,
                                 @"g_name":goodsName,
                                 @"g_jingle":@"sdfsdfsdfgggg",
                                 @"g_price":goodsPrice,
                                 @"g_marketprice":marketPrice,
                                 @"g_costprice":@"1",
                                 @"g_discount":@"1",
                                 @"g_storage":goodsStore,
                                 @"image_path":imageNames,
                                 @"g_body":goodsDescription,
                                 @"g_state":@"1",
                                 @"g_freight":goodsFreight,
                                 @"g_commend":@"1",
                                 @"key":userKey,
                                 @"type_id":@"0",
                                 @"is_fc":@"0",
                                 @"b_id":@"0",
                                 };
    
//    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
//    NSString *json = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
//    NSDictionary *param = @{@"body":json};
    
    [NetworkClient requestWithUrl:@"index.php?act=seller_goods&op=save_goods"
                           params:parameters
                          success:^(id response) {
                              STMLoginModel *info = [[STMLoginModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                              success(info);
                          }
                          failure:^(NSError *err) {
                              failure(err);
                          }];
}

//获取商品信息
+ (void)getGoodsInfoWithKey:(NSString *)userKey
                   commonId:(NSString *)commonId
                    success:(void (^)(STMGoodsInfoModel *result))success
                    failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"key":userKey};
    
    [NetworkClient requestWihtMethod:RequestMethodTypePost
                                 url:[NSString stringWithFormat:@"index.php?act=seller_goods&op=edit_goods&commonid=%@", commonId]
                              params:parameters
                             success:^(id response) {
                                 STMGoodsInfoModel *info = [[STMGoodsInfoModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                                 success(info);
                             }
                             failure:^(NSError *err) {
                                 failure(err);
                             }];
}

//编辑商品保存
+ (void)editGoodsSaveWithKey:(NSString *)userKey
                    commonid:(NSString *)commonid
                  imageNames:(NSString *)imageNames
                   goodsName:(NSString *)goodsName
                 goodsCateId:(NSString *)goodsCateId
               goodsCateName:(NSString *)goodsCateName
                  goodsPrice:(NSString *)goodsPrice
                 marketPrice:(NSString *)marketPrice
                  goodsStore:(NSString *)goodsStore
                goodsFreight:(NSString *)goodsFreight
            goodsDescription:(NSString *)goodsDescription
                     success:(void (^)(STMLoginModel *result))success
                     failure:(void (^)(NSError *err))failure {
    NSDictionary *parameters = @{@"commonid":commonid,
                                 @"form_submit":@"ok",
                                 @"cate_id":goodsCateId,
                                 @"cate_name":goodsCateName,
                                 @"g_name":goodsName,
                                 @"g_jingle":@"sdfsdfsdfgggg",
                                 @"g_price":goodsPrice,
                                 @"g_marketprice":marketPrice,
                                 @"g_costprice":@"1",
                                 @"g_discount":@"1",
                                 @"g_storage":goodsStore,
                                 @"image_path":imageNames,
                                 @"g_body":goodsDescription,
                                 @"g_state":@"1",
                                 @"g_freight":goodsFreight,
                                 @"g_commend":@"1",
                                 @"key":userKey,
                                 @"type_id":@"0",
                                 @"is_fc":@"0",
                                 @"b_id":@"0",
                                 };
    
    //    NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];
    //    NSString *json = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
    //    NSDictionary *param = @{@"body":json};
    
    [NetworkClient requestWithUrl:@"index.php?act=seller_goods&op=edit_save_goods"
                           params:parameters
                          success:^(id response) {
                              STMLoginModel *info = [[STMLoginModel alloc] initWithDictionary:(NSDictionary *)response error:nil];
                              success(info);
                          }
                          failure:^(NSError *err) {
                              failure(err);
                          }];
}


@end
